Skip to content

Update best_practices.rst #12617

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 12, 2019
Merged

Update best_practices.rst #12617

merged 1 commit into from
Nov 12, 2019

Conversation

amine-betari
Copy link
Contributor

@amine-betari amine-betari commented Nov 10, 2019

// there is a public "router" service in the container
$router = $this->container->get('router');

// this will not Work: MailLogger is a private service
$mailLogger = $this->container->get(MailLogger::class);

@javiereguiluz
Copy link
Member

@amine-betari thanks! This is correct ... but the reword implies that you can access to ALL public services, and that's not true. So ... what if reword this again and say something like this:

If you extend the base ``AbstractController``, you can only access to
the most common services (e.g. ``twig``, ``router``, ``doctrine``, etc.).
via ``$this->container->get()`` or ``$this->get()``. Use dependency
injection to fetch the rest of services [...]

@amine-betari
Copy link
Contributor Author

amine-betari commented Nov 10, 2019

@javiereguiluz done

thank's. I thought we could access to all public services

Copy link
Contributor

@OskarStark OskarStark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to merge it

@OskarStark
Copy link
Contributor

Thank you @amine-betari.

OskarStark added a commit that referenced this pull request Nov 12, 2019
This PR was squashed before being merged into the 4.3 branch (closes #12617).

Discussion
----------

Update best_practices.rst

// there is a public "router" service in the container
       $router = $this->container->get('router');

// this will not Work: MailLogger is a private service
     $mailLogger = $this->container->get(MailLogger::class);

Commits
-------

fcddead Update best_practices.rst
@OskarStark OskarStark merged commit fcddead into symfony:4.3 Nov 12, 2019
OskarStark added a commit that referenced this pull request Nov 12, 2019
OskarStark added a commit that referenced this pull request Nov 12, 2019
* 4.3:
  fix linelength. refs #12617
OskarStark added a commit that referenced this pull request Nov 12, 2019
* 4.4:
  fix linelength. refs #12617
  Update best_practices.rst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants